import { createWebHistory, createRouter } from "vue-router";
import Layout from "@/layout";

/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                  // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                  // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'               // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
 * meta : {
    noCache: true                   // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'                // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false               // 如果设置为false，则不会在breadcrumb面包屑中显示
    activeMenu: '/system/user'      // 当路由设置了该属性，则会高亮相对应的侧边栏。
  }
 */

// 公共路由
export const constantRoutes = [
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path(.*)",
        component: () => import("@/views/redirect/index.vue"),
      },
    ],
  },
  {
    path: "/login",
    component: () => import("@/views/login"),
    hidden: true,
  },
  {
    path: "/register",
    component: () => import("@/views/register"),
    hidden: true,
  },
  {
    path: "/:pathMatch(.*)*",
    component: () => import("@/views/error/404"),
    hidden: true,
  },
  {
    path: "/401",
    component: () => import("@/views/error/401"),
    hidden: true,
  },
  {
    path: "/",
    component: Layout,
    redirect: "/index",
    children: [
      {
        path: "index",
        component: () => import("@/views/index"),
        name: "Index",
        meta: { title: "首页", icon: "dashboard", affix: true },
      },
    ],
  },
  {
    path: "/activities",
    component: Layout,
    hidden: true,
    redirect: "/activities/incident",
    children: [
      {
        path: "/activities/incident",
        component: () => import("@/views/business/activities/incident.vue"),
        name: "incident",
        meta: { title: "单个安保事件管理" },
      },
    ],
  },
  {
    path: "/assess",
    component: Layout,
    hidden: true,
    redirect: "/assess/mapSurvey",
    children: [
      {
        path: "earthquake",
        component: () => import("@/views/assess/earthquake/index"),
        name: "earthquake",
        meta: { title: "地震危险性评估" },
      },
      {
        path: "house",
        component: () => import("@/views/assess/house/index"),
        name: "house",
        meta: { title: "房屋地震灾害风险评估" },
      },
      {
        path: "secondary",
        component: () => import("@/views/assess/secondary/index"),
        name: "secondary",
        meta: { title: "次生灾害隐患评估" },
      },
      {
        path: "population",
        component: () => import("@/views/assess/population/index"),
        name: "population",
        meta: { title: "人口伤亡评估" },
      },
      {
        path: "urgency",
        component: () => import("@/views/assess/urgency/index"),
        name: "urgency",
        meta: { title: "需紧急安置人员" },
      },
      {
        path: "emphasis",
        component: () => import("@/views/assess/emphasis/index"),
        name: "emphasis",
        meta: { title: "重点场所风险评估" },
      },
    ],
  },
  {
    path: "/user",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "profile",
        component: () => import("@/views/system/user/profile/index"),
        name: "Profile",
        meta: { title: "个人中心", icon: "user" },
      },
    ],
  },
  {
    path: "/system/user-auth",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "role/:userId(\\d+)",
        component: () => import("@/views/system/user/authRole"),
        name: "AuthRole",
        meta: { title: "分配角色", activeMenu: "/system/user" },
      },
    ],
  },
  {
    path: "/system/role-auth",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "user/:roleId(\\d+)",
        component: () => import("@/views/system/role/authUser"),
        name: "AuthUser",
        meta: { title: "分配用户", activeMenu: "/system/role" },
      },
    ],
  },
  {
    path: "/system/dict-data",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "index/:dictId(\\d+)",
        component: () => import("@/views/system/dict/data"),
        name: "Data",
        meta: { title: "字典数据", activeMenu: "/system/dict" },
      },
    ],
  },
  {
    path: "/monitor/job-log",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "index",
        component: () => import("@/views/monitor/job/log"),
        name: "JobLog",
        meta: { title: "调度日志", activeMenu: "/monitor/job" },
      },
    ],
  },
  {
    path: "/tool/gen-edit",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "index/:tableId(\\d+)",
        component: () => import("@/views/tool/gen/editTable"),
        name: "GenEdit",
        meta: { title: "修改生成配置", activeMenu: "/tool/gen" },
      },
    ],
  },
  {
    path: "/mapQuery",
    component: Layout,
    hidden: true,
    meta: { title: "地震动参数区划图查询", icon: "mapQuery" },
    children: [
      {
        path: "viewAndShow",
        component: () => import("@/views/mapQuery/viewAndShow/index"),
        name: "viewAndShow",
        meta: { title: "查看及展示", icon: "viewAndShow" },
      },
    ],
  },
  //安评成果库
  {
    path: "/safetyEvalutionResultsBank",
    component: Layout,
    hidden: true,
    meta: { title: "安评成果库", icon: "safetyEvalutionResultsBank" },
    children: [
      {
        path: "safetyEvaResCatRegister", // /:operate/:id
        component: () =>
          import(
            "@/views/safetyEvalutionResultsBank/safetyEvaResCatRegister/index"
          ),
        name: "safetyEvaResCatRegister",
        meta: { title: "安评成果目录登记", icon: "safetyEvaResCatRegister" },
      },
      {
        path: "registerView/:projectid",
        component: () =>
          import(
            "@/views/safetyEvalutionResultsBank/safetyEvaResCatRegister/registerView"
          ),
        name: "registerView",
        meta: { title: "安评成果目录登记查看", icon: "registerView" },
      },
      {
        path: "safetyEvaResCatManagement",
        component: () =>
          import(
            "@/views/safetyEvalutionResultsBank/safetyEvaResCatManagement/main"
          ),
        name: "safetyEvaResCatManagement",
        meta: { title: "安评成果目录管理", icon: "safetyEvaResCatManagement" },
        children: [
          {
            path: "projectInformationManagement",
            component: () =>
              import(
                "@/views/safetyEvalutionResultsBank/safetyEvaResCatManagement/index"
              ),
            name: "projectInformationManagement",
            meta: {
              title: "安评成果目录项目信息管理",
              icon: "projectInformationManagement",
            },
          },
          {
            path: "holelocationInformationManagement",
            component: () =>
              import(
                "@/views/safetyEvalutionResultsBank/safetyEvaResCatManagement/holelocationInformationManagement"
              ),
            name: "holelocationInformationManagement",
            meta: {
              title: "安评成果目录孔位信息管理",
              icon: "holelocationInformationManagement",
            },
          },
        ],
      },
    ],
  },
  //区评成果库
  {
    path: "/regionalEvalutionResultsBank",
    component: Layout,
    hidden: true,
    meta: { title: "区评成果库", icon: "regionalEvalutionResultsBank" },
    children: [
      {
        path: "regionalEvaResCatRegister", // /:operate/:id
        component: () =>
          import(
            "@/views/regionalEvalutionResultsBank/regionalEvaResCatRegister/index"
          ),
        name: "regionalEvaResCatRegister",
        meta: { title: "区评成果目录登记", icon: "regionalEvaResCatRegister" },
      },
      {
        path: "registerView/:projectid",
        component: () =>
          import(
            "@/views/regionalEvalutionResultsBank/regionalEvaResCatRegister/registerView"
          ),
        name: "regionalRegisterView",
        meta: { title: "区评成果目录登记查看", icon: "registerView" },
      },
      {
        path: "regionalEvaResCatManagement",
        component: () =>
          import(
            "@/views/regionalEvalutionResultsBank/regionalEvaResCatManagement/main"
          ),
        name: "regionalEvaResCatManagement",
        meta: {
          title: "区评成果目录管理",
          icon: "regionalEvaResCatManagement",
        },
        children: [
          {
            path: "regionalEvaResCatProject",
            component: () =>
              import(
                "@/views/regionalEvalutionResultsBank/regionalEvaResCatManagement/index"
              ),
            name: "regionalEvaResCatProject",
            meta: {
              title: "区评成果目录项目信息管理",
              icon: "projectInformationManagement",
            },
          },
          {
            path: "regionalEvaResCaHolelocationt",
            component: () =>
              import(
                "@/views/regionalEvalutionResultsBank/regionalEvaResCatManagement/holelocationInformationManagement"
              ),
            name: "regionalEvaResCaHolelocationt",
            meta: {
              title: "区评成果目录孔位信息管理",
              icon: "holelocationInformationManagement",
            },
          },
        ],
      },
    ],
  },

  //小区划成果库
  {
    path: "/microzonationEvalutionResultsBank",
    component: Layout,
    hidden: true,
    meta: { title: "小区划成果库", icon: "microzonationEvalutionResultsBank" },
    children: [
      {
        path: "microzonationEvaResCatRegister", // /:operate/:id
        component: () =>
          import(
            "@/views/microzonationEvalutionResultsBank/microzonationEvaResCatRegister/index"
          ),
        name: "microzonationEvaResCatRegister",
        meta: {
          title: "小区划成果目录登记",
          icon: "microzonationEvaResCatRegister",
        },
      },
      {
        path: "registerView/:projectid",
        component: () =>
          import(
            "@/views/microzonationEvalutionResultsBank/microzonationEvaResCatRegister/registerView"
          ),
        name: "microzonationRegisterView",
        meta: { title: "小区划成果目录登记查看", icon: "registerView" },
      },
      {
        path: "microzonationEvaResCatManagement",
        component: () =>
          import(
            "@/views/microzonationEvalutionResultsBank/microzonationEvaResCatManagement/main"
          ),
        name: "microzonationEvaResCatManagement",
        meta: {
          title: "小区划成果目录管理",
          icon: "microzonationEvaResCatManagement",
        },
        children: [
          {
            path: "microzonationEvaResCatProject",
            component: () =>
              import(
                "@/views/microzonationEvalutionResultsBank/microzonationEvaResCatManagement/index"
              ),
            name: "microzonationEvaResCatProject",
            meta: {
              title: "小区划成果目录项目信息管理",
              icon: "projectInformationManagement",
            },
          },
          {
            path: "microzonationEvaResCaHolelocationt",
            component: () =>
              import(
                "@/views/microzonationEvalutionResultsBank/microzonationEvaResCatManagement/holelocationInformationManagement"
              ),
            name: "microzonationEvaResCaHolelocationt",
            meta: {
              title: "小区划成果目录孔位信息管理",
              icon: "holelocationInformationManagement",
            },
          },
        ],
      },
    ],
  },
  // 抗震设防成果数据管理
  {
    path: "/earthquakeLevelResultManage",
    component: Layout,
    hidden: true,
    meta: {
      title: "抗震设防成果数据管理",
      icon: "earthquakeLevelResultManage",
    },
    children: [
      {
        path: "provinceResultManage",
        component: () =>
          import(
            "@/views/earthquakeLevelResultManage/provinceResultManage/main"
          ),
        name: "provinceResultManage",
        meta: { title: "省级成果数据管理", icon: "provinceResultManage" },
        children: [
          {
            path: "provinceResultProjectManage",
            component: () =>
              import(
                "@/views/earthquakeLevelResultManage/provinceResultManage/provinceResultProjectManage/index"
              ),
            name: "provinceResultProjectManage",
            meta: {
              title: "省级成果数据项目信息管理",
              icon: "provinceResultProjectManage",
            },
          },
          {
            path: "provinceResultHoleLocationManage",
            component: () =>
              import(
                "@/views/earthquakeLevelResultManage/provinceResultManage/provinceResultHoleLocationManage/index"
              ),
            name: "provinceResultHoleLocationManage",
            meta: {
              title: "省级成果数据孔位信息管理",
              icon: "provinceResultHoleLocationManage",
            },
          },
        ],
      },

      {
        path: "bureauLevelResultManage",
        component: () =>
          import(
            "@/views/earthquakeLevelResultManage/bureauLevelResultManage/main"
          ),
        name: "bureauLevelResultManage",
        meta: { title: "局级成果数据管理", icon: "bureauLevelResultManage" },
        children: [
          {
            path: "bureauLevelResultProjectManage",
            component: () =>
              import(
                "@/views/earthquakeLevelResultManage/bureauLevelResultManage/bureauLevelResultProjectManage/index"
              ),
            name: "bureauLevelResultProjectManage",
            meta: {
              title: "局级成果数据项目信息管理",
              icon: "bureauLevelResultProjectManage",
            },
          },
          {
            path: "bureauLevelResultHoleLocationManage",
            component: () =>
              import(
                "@/views/earthquakeLevelResultManage/bureauLevelResultManage/bureauLevelResultHoleLocationManage/index"
              ),
            name: "bureauLevelResultHoleLocationManage",
            meta: {
              title: "局级成果数据孔位信息管理",
              icon: "bureauLevelResultHoleLocationManage",
            },
          },
        ],
      },

      {
        path: "adminManage",
        component: () =>
          import("@/views/earthquakeLevelResultManage/adminManage/main"),
        name: "adminManage",
        meta: { title: "管理员管理", icon: "adminManage" },
        children: [
          {
            path: "adminProjectManage",
            component: () =>
              import(
                "@/views/earthquakeLevelResultManage/adminManage/adminProjectManage/index"
              ),
            name: "adminProjectManage",
            meta: {
              title: "管理员项目信息管理",
              icon: "adminProjectManage",
            },
          },
          {
            path: "adminHoleLocationManage",
            component: () =>
              import(
                "@/views/earthquakeLevelResultManage/adminManage/adminHoleLocationManage/index"
              ),
            name: "adminHoleLocationManage",
            meta: {
              title: "管理员孔位信息管理",
              icon: "adminHoleLocationManage",
            },
          },
        ],
      },
    ],
  },

  // 钻孔信息综合查询
  {
    path: "/drillingInfoCompreQuery",
    component: Layout,
    hidden: true,
    meta: { title: "钻孔信息综合查询", icon: "drillingInfoCompreQuery" },
    children: [
      {
        path: "compreQuery",
        component: () =>
          import(
            "@/views/drillingInfoCompreQuery/resultManage/compreQuery"
          ),
        name: "compreQuery",
        meta: {
          title: "钻孔信息综合查询",
          icon: "compreQuery",
        },
      },
      {
        path: "drillHoleDisplay",
        component: () =>
          import(
            "@/views/drillingInfoCompreQuery/resultManage/drillHoleDisplay"
          ),
        name: "drillHoleDisplay",
        meta: {
          title: "钻孔展示页面",
          icon: "drillHoleDisplay",
        },
      },
    ],
  },

  // 地震动参数管理
  {
    path: "/groundMotionParamManage ",
    component: Layout,
    hidden: true,
    meta: { title: "地震动参数管理", icon: "groundMotionParamManage" },
    children: [
      {
        path: "groundMotionParam",
        component: () =>
          import(
            "@/views/groundMotionParamManage/resultManage/groundMotionParam"
          ),
        name: "groundMotionParam",
        meta: {
          title: "参数管理",
          icon: "groundMotionParam",
        },
      },
      {
        path: "queryDetails",
        component: () =>
          import(
            "@/views/groundMotionParamManage/resultManage/queryDetails"
          ),
        name: "queryDetails",
        meta: {
          title: "查询详细界面",
          icon: "queryDetails",
        },
      },
    ],
  },
];

// 动态路由，基于用户权限动态去加载
export const dynamicRoutes = []

const router = createRouter({
  history: createWebHistory(import.meta.env.VITE_APP_ROUTE),
  routes: constantRoutes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    } else {
      return { top: 0 };
    }
  },
});

export default router;
